package com.spic.system.api.factory;

import com.spic.common.core.domain.R;
import com.spic.system.api.RemoteDeptService;
import com.spic.system.api.domain.SysDept;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Description 部门服务错误处理
 * @Author AnQi
 * @Date 2021/11/28
 */
@Component
public class RemoteDeptFallbackFallbackFactory implements FallbackFactory<RemoteDeptService> {
    @Override
    public RemoteDeptService create(Throwable cause) {
        return new RemoteDeptService(){

            @Override
            public R<List<Long>> getCustomDeptIds(Long roleId) {
                return R.fail("获取自定义部门权限id失败:" + cause.getMessage());
            }

            @Override
            public R<List<Long>> getDeptAndChildren(Long deptId) {
                return R.fail("获取部门及子部门id失败:" + cause.getMessage());
            }

            @Override
            public R<String> getDeptName(Long deptId) {
                return R.fail("获取部门名称失败:" + cause.getMessage());
            }

            @Override
            public R<List<Long>> getDeptLeaderIdDeptIds(String deptIds) {
                return R.fail("获取部门领导Id失败:" + cause.getMessage());
            }

            @Override
            public R<Long> addDept(SysDept sysDept) {
                return R.fail("添加部门失败:" + cause.getMessage());
            }

            @Override
            public R<Map<String, Long>> cache2()
            {
                return R.fail("添加部门失败:" + cause.getMessage());
			}
			
            public R<String> getSysDeptBychildenId(Long deptId)
            {
                return R.fail("查询父部门失败:" + cause.getMessage());
            }
        };
    }
}
